package com.zhike.listener;


import com.zhike.core.ActionListener;
import com.zhike.core.Failure;
import com.zhike.core.StatusListener;
import com.zhike.handler.IncidentDetailHandler;

import net.cellcloud.talk.dialect.ActionDialect;


public class IncidentDetailListener implements ActionListener, StatusListener {

	public static final String ACTION_NAME = "requestIncidentDetail";

	private IncidentDetailHandler handler;

	public IncidentDetailListener(IncidentDetailHandler handler) {
		this.handler = handler;
	}

	@Override
	public void onAction(ActionDialect action) {
		this.handler.obtainMessage(IncidentDetailHandler.MSG_ACTION, action).sendToTarget();
	}

	@Override
	public void onConnected(String identifier) {
		this.handler.obtainMessage(IncidentDetailHandler.MSG_CONNECT, identifier).sendToTarget();
	}

	@Override
	public void onDisconnected(String identifier) {
		this.handler.obtainMessage(IncidentDetailHandler.MSG_DISCONNECT, identifier).sendToTarget();
	}

	@Override
	public void onFailed(String identifier, Failure failure) {
		this.handler.obtainMessage(IncidentDetailHandler.MSG_FAILURE, failure).sendToTarget();
	}
}
